package com.imooc.springboot.dubbo.nilinili.provider.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.imooc.springboot.dubbo.nilinili.entity.bean.PageBean;
import com.imooc.springboot.dubbo.nilinili.entity.dto.PhotographerDTO;
import com.imooc.springboot.dubbo.nilinili.entity.dto.PhotographerWorkDTO;
import com.imooc.springboot.dubbo.nilinili.provider.entity.po.PhotographerPo;
import com.imooc.springboot.dubbo.nilinili.provider.entity.po.PhotographerWorkPo;
import com.imooc.springboot.dubbo.nilinili.provider.mapper.PhotographerMapper;
import com.imooc.springboot.dubbo.nilinili.provider.utils.BeanCopierUtil;
import com.imooc.springboot.dubbo.nilinili.service.PhotographerService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service(interfaceClass = PhotographerService.class)
public class PhotographerServiceImpl implements PhotographerService {
    @Autowired
    private PhotographerMapper photographerMapper;

    @Override
    public PageBean<PhotographerDTO> getAllUserInfo(int pageNum) {
        PageHelper.startPage(pageNum, 10);
        List<PhotographerPo> photographerPOs=photographerMapper.getAllUserInfo();
        PageBean<PhotographerPo> pageInfo= new PageBean<>(photographerPOs);
        PageBean<PhotographerDTO> pageBean=BeanCopierUtil.CopyPageBean(pageInfo, PhotographerDTO.class);
        return pageBean;
    }

    @Override
    public List<PhotographerWorkDTO> getUserWorks(Integer user_id) {
        List<PhotographerWorkPo> photographerWorkPOS=photographerMapper.getUserWorks(user_id);
        return BeanCopierUtil.copyObjects(photographerWorkPOS, PhotographerWorkDTO.class);


    }
}
